home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / mi33.zip / MI33.ASM < prev    next >
Assembly Source File  |  1993-07-17  |  5KB  |  146 lines

  1. ;------------------------------------------------------------------------------
  2. ;MI33.ASM : 16-July-1993 : A PWB make-me-happy mouse driver wrapper    
  3. ;------------------------------------------------------------------------------
  4. ;Simple mouse INT33 wrapper for applications that like to leave the
  5. ;mouse cursor at center-screen after a hardware/software mouse reset
  6. ;functions 0 & 33. Object here is to trap these functions and position
  7. ;mouse cursor to upper-left. This doesn't prevent later mouse cursor
  8. ;positioning, but that's not the problem; the problem is apps that
  9. ;just do a reset and leave you to reposition the mouse cursor. One
  10. ;prime example is PWB. At startup, sure, it positions the mouse cursor
  11. ;to the last-at one, but on return from a compile, make, etc., the
  12. ;mouse cursor always goes to center-screen (my only "problem" with PWB).
  13. ;I was going to patch the mouse driver, but that would be version-specific,
  14. ;not to mention that it's a tangle web in there. Anyway, here we go. Simple,
  15. ;like I said. Written using MASM 6.1a, but I don't think I'll use any
  16. ;6.1a-specific stuff (should work with any MASM).
  17. ;------------------------------------------------------------------------------
  18. ;For any future changes, call my BBS. The BBS features all sorts of programmer
  19. ;toolkits such as:
  20. ; BULLET: super-fast dBASE file managers (BLTQ13.ZIP, BLTC13.ZIP)
  21. ; RUCKUS: multi-soundcard, MOD/VOC/WAV/MIDI/CMF/ROL-cnv (RUKQ10.ZIP, RUKC10.ZIP)
  22. ; and too many other programmer toolkits to mention here. BTW, the Qxx and
  23. ; Cxx in RUCKUS and BULLET are for QB,BASIC7,VBDOS, and DOS C compiler,
  24. ; respectively. xx is distribution number and will change.
  25. ;
  26. ;    BBS support telephone: 1(210)684-8065. V.32bis (1200-14.4k bps)
  27. ;Hours: Monday through Friday, 5pm to 9am next morning
  28. ;    Weekend hours are 1pm to 9am next morning.
  29. ;    All times USA Central Time, about UTCtime-5.
  30. ;
  31. ;This code is public domain, do what you will. Just never forget
  32. ;that it was written by:
  33. ; Cornel Huth (chuth@lonestar.utsa.edu) (Fidonet 1:387/822.8)
  34. ; 6402 Ingram Rd/San Antonio, TX 78238/U.S.A.
  35. ;------------------------------------------------------------------------------
  36.  
  37. _text SEGMENT 'code'    
  38.         ORG 100h
  39.  
  40. BPTR EQU <BYTE PTR>
  41. WPTR EQU <WORD PTR>
  42.  
  43. start:        jmp    install
  44.         
  45.         ORG 150h    ;sure, filesize is 80 bytes larger, but
  46.                 ;still takes as a cluster, anyway, plus
  47.                 ;we save twice that resident-memory use
  48.  
  49. orgMouse33    DWORD 33494D2Dh
  50. orgFuncNo    WORD 2D33h
  51.         
  52.         ORG 160h    ;the resident code will be moved down
  53.                 ;into the PSP at PSP:60h (para aligned entry)
  54.                                 
  55.         ;INT33 comes here before MOUSE.COM/SYS/EXE code.
  56.         ;This saves func#, routes to original, then checks
  57.         ;if it's a reset func. If so, issues a SET MOUSE CURSOR
  58.         ;POSITION to 0,0 and returns to caller.
  59.  
  60. MI33:        mov    cs:orgFuncNo-100h,ax
  61.         pushf            
  62.         call    cs:[orgMouse33-100h]
  63.         push    ax
  64.         mov    ax,cs:orgFuncNo-100h
  65.         or    ax,ax        ;func 0
  66.         jz    MI33work    ;or
  67.         cmp    ax,33        ;func 33 (decimal)
  68.         je    MI33work    ;then work to do
  69. MI33xit:    pop    ax        ;ax from mouse driver
  70.         iret            ;and back
  71.  
  72. MI33work:    push    cx        ;simple enough, if a mouse reset
  73.         push    dx        ;was called, move the mouse cursor
  74.         sub    cx,cx        ;to the upper-left of screen
  75.         mov    dx,cx
  76.         mov    ax,4
  77.         int 33h
  78.         pop    dx
  79.         pop    cx
  80.         jmp    MI33xit
  81.  
  82.         ;-------------- end of resident code --------------
  83.         ;Install using as little resident space as possible
  84.         ;Nothing fancy here, expected to be loaded AFTER
  85.         ;MOUSE.COM/SYS/EXE and to remain in memory forever.
  86.         ;Also requires DOS 3+.
  87.  
  88. install:    mov    ah,30h
  89.         int 21h
  90.         cmp    al,3
  91.         mov    dx,OFFSET Bomb0msg
  92.         jb    StdOut
  93.         
  94.         mov    ax,3533h
  95.         int 21h            
  96.         cmp    BPTR es:[bx],0CFh ;es:bx->mouse entry code, IRET only?
  97.         mov    dx,OFFSET Bomb1msg
  98.         je    StdOut
  99.         
  100.         ;checks out so install
  101.         
  102.         mov    WPTR cs:[orgMouse33],bx    ;save mouse driver entry
  103.         mov    WPTR cs:[orgMouse33+2],es
  104.         
  105.         ;release environment
  106.         
  107.         mov    es,WPTR cs:[2Ch]    ;PSP:2C=environ segment
  108.         mov    ah,49h
  109.         int 21h
  110.         
  111.         ;transplant MI33 code -100h bytes relative (into PSP)
  112.         ;(saves significant number of bytes for a 30-byte program)
  113.         
  114.         push    cs
  115.         push    cs
  116.         pop    ds
  117.         pop    es
  118.         mov    si,OFFSET orgMouse33    ;ds:si->cs:150 (150h)
  119.         mov    di,50h            ;es:di->PSP:50 ( 50h)
  120.         mov    cx,OFFSET install-150h    ;size in bytes
  121.         rep movsb
  122.         
  123.         mov    dx,OFFSET MI33-100h    ;ds:dx->MI33
  124.         mov    ax,2533h        ;set INT33 vector
  125.         int 21h
  126.         mov    dx,OFFSET Installmsg
  127.  
  128. StdOut:        push    cs
  129.         pop    ds
  130.         mov    ah,9
  131.         int 21h
  132.         cmp    dx,OFFSET Installmsg
  133.         jne    BombOut
  134.         mov    dx,OFFSET install-100h    ;relative PSP:0
  135.         int 27h        
  136.  
  137. BombOut:    mov    ax,4C01h
  138.         int 21h
  139.  
  140. Bomb0msg    db "DOS 3+ needed",13,10,"$"
  141. Bomb1msg    db "INT33->iret",13,10,"$"
  142. Installmsg    db "MI33 installed",13,10,"$"
  143.  
  144. _text ENDS
  145.         END start
  146.